package cn.zysheep.lang3;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.FastDateFormat;
import org.junit.jupiter.api.Test;

import java.util.Date;

/**
 * @version v1.0
 * @Author: lyw
 * @Date: 2021/8/9
 */
public class DateFormatUtilsTest {

    @Test
    public void testFormat() {
        //将日期转为指定格式的字符串
        String format = DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss");

        // 内置常量
        FastDateFormat format1 = DateFormatUtils.ISO_8601_EXTENDED_DATETIME_FORMAT;
        String format2 = format1.format(new Date());

        System.out.printf("%s  \n %s",format,format2);
    }
}
